package com.cloudsigns.factorymanager2.project.presenter;

import com.cloudsigns.factorymanager2.project.iview.IAddEngineeringConstructOrderView;
import com.cloudsigns.factorymanager2.project.model.AddEngineeringConstructOrderModel;
import com.cloudsigns.factorymanager2.project.model.IAddEngineeringConstructOrderModel;

/**
 * Created by tony on 2018/3/21.
 */

public class AddEngineeringConstructOrderPresenter {
    private IAddEngineeringConstructOrderView view;
    private IAddEngineeringConstructOrderModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public AddEngineeringConstructOrderPresenter(IAddEngineeringConstructOrderView view) {
        this.view = view;
        this.model = new AddEngineeringConstructOrderModel();
    }

    public void addEngineeringConstructOrder() {


        model.addEngineeringConstructOrder(view.getCompleteDate(), view.getConstructPartList(), view.getEngineeringAddress(), view.getEngineeringName(), view.getLat(), view.getLon(), view.getProjectName(), view.getProductList(), new AddEngineeringConstructOrderModel.OnAddEngineeringConstructOrderListener() {
            @Override
            public void success(final String projectId) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.addEngineeringConstructOrderSuccess(projectId);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {

            }
        });

    }

}
